<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    <title>支付宝支付</title>
</head>
<body>

<div style="margin:300px auto;width: 1200px;text-align: center;">
    <form action="{:url('home/order/pay')}" method="post" class="form">
        商品名称：<input type="text" name="username" id="username">
        <br>
        <br>
        商品数量：<input type="number" name="number" id="number">
        <br>
        <br>
        商品价格：<input type="number" name="price" id="price">
        <br>
        <br>
        <button class="btn" type="button">购买</button>
    </form>
</div>
</body>
</html>

<script>
    $(function(){
        $(".btn").click(function(){
            var flag = true;

            if($("#username").val() == ""){
                alert("商品名称不允许为空");
                flag = false;
            }

            if($("#number").val() == ""){
                alert("商品数量不允许为空");
                flag = false;
            }

            if($("#price").val() == ""){
                alert("商品价格不允许为空");
                flag = false;
            }

            if(flag){
                $(".form").submit();
            }

        })
    })
</script>

